﻿<Window x:Class="DataBinding.DataGridTest"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="DataGridTest" Height="300" Width="300"
         xmlns:local="clr-namespace:DataBinding">

    <Window.Resources>
        <local:ImagePathConverter x:Key="ImagePathConverter"></local:ImagePathConverter>
    </Window.Resources>
    
    <Grid>

        <DataGrid x:Name="gridProducts" Margin="5" AutoGenerateColumns="False" RowHeight="100" LoadingRow="gridProducts_LoadingRow"
                  FrozenColumnCount="1">

            <DataGrid.Columns>
                <DataGridTextColumn Header="Product" Width="175" Binding="{Binding ModelName}"></DataGridTextColumn>
                <DataGridTextColumn Header="Price" Binding="{Binding UnitCost, StringFormat={}{0:C}}"></DataGridTextColumn>
                <DataGridTextColumn Header="Model Number" Binding="{Binding ModelNumber}"></DataGridTextColumn>

                <DataGridTextColumn Width="400" Binding="{Binding Description}" Header="Description">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextWrapping" Value="Wrap"></Setter>
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>

                <DataGridTextColumn IsReadOnly="True" Header="Category" Binding="{Binding CategoryName}"></DataGridTextColumn>


                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Stretch="None"
						 Source="{Binding ProductImagePath, Converter={StaticResource ImagePathConverter}}" >
                            </Image>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>
